public class Test {
    //水仙花数
    public static void main(String[] args) {
        for(int i = 1; i<=99999;i++){
            int count = 0;
            int tmp = i;
            int sum = 0;
            while(tmp != 0){
                tmp /= 10;
                count++;
            }
            //count里面就储存了当前数字是几位数
            tmp= i;
            while(tmp != 0){
                sum += Math.pow(tmp%10,count);
                tmp  /=  10;

            }
            //sum储存了和
            if(sum == i){
                System.out.println(i);
            }

        }
    }

}
